$(function () {
    var allLis = $('.item li')
    var barcode = GetQueryString("barcode");
    $.get("http://193.112.10.21/gas/info/" + barcode, function(res, status){
        if (status === 'success') {
            var data = res.data
            var params = [
                data.tankBarcode,
                data.productNumber,
                fillter(data.gmtCreate),
                fillter(data.inspectionDate),
                fillter(data.scrapTime),
                data.tankStatus,
                data.tankType,
                data.fillUsername,
                data.fillUnit,
                data.fillMedium,
                data.fillWeight,
                fillter(data.lastFillTime),
                data.customerName,
                data.idCardNumber,
                data.deliveryAddress,
                data.deliveryUsername,
                fillter(data.deliveryTime)
            ]
            params.forEach(function (item, index) {
                allLis[index].innerText += item
            })
        }
    })
    function fillter (val) {
        if (val === null) {
            return ''
        }
        var data = new Date(parseInt(val))
        var timeY = data.toTimeString().substr(0, 8)
        var timeM = data.toLocaleDateString()
        return timeM + ' ' + timeY
    }

    function GetQueryString (name) {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)")
        var r = window.location.search.substr(1).match(reg)
        if(r!=null)
            return unescape(r[2])
        return null
    }
})